package tp.pr5.gui;

import tp.pr5.Controller;
import tp.pr5.RobotEngine;
import tp.pr5.Rotation;
import tp.pr5.instructions.DefuseInstruction;
import tp.pr5.instructions.DropInstruction;
import tp.pr5.instructions.MoveInstruction;
import tp.pr5.instructions.OperateInstruction;
import tp.pr5.instructions.PickInstruction;
import tp.pr5.instructions.QuitInstruction;
import tp.pr5.instructions.StormInstruction;
import tp.pr5.instructions.TriggerInstruction;
import tp.pr5.instructions.TurnInstruction;

public class GUIController extends Controller
{
	/**
	 * Constructor that uses the model
	 * 
	 * @param robot - The reference to the model
	 */
	public GUIController(RobotEngine game) 
	{
		super(game);
	}

	/**
	 * Abstract method that runs the game. This method is different whether the application runs the game on console or on a Swing Window
	 * 
	 */
	public void startController()
	{
		game.requestStart();
	}
	
	/**
	 * Executes an OPERATE instruction
	 * 
	 * @param itemName - Name of the used item
	 */
	public void executeOperateAction(String itemName)
	{
		game.communicateRobot(new OperateInstruction(itemName));
	}
	
	/**
	 * Executes a DROP instruction
	 * 
	 * @param item - Item dropped
	 */
	public void executeDropAction(String item)
	{
		game.communicateRobot(new DropInstruction(item));
	}
	
	/**
	 * Executes a PICK instruction
	 * 
	 * @param item - Item picked
	 */
	public void executePickAction(String item)
	{
		game.communicateRobot(new PickInstruction(item));
	}
	
	/**
	 * Executes a QUIT instruction
	 * 
	 */
	public void executeQuitAction()
	{
		game.communicateRobot(new QuitInstruction());
	}
	
	/**
	 * Executes a MOVE instruction
	 * 
	 */
	public void executeMoveAction()
	{
		game.communicateRobot(new MoveInstruction());		
	}
	
	/**
	 * Executes a TURN instruction
	 * 
	 * @param rotation - Rotation of the robot (LEFT, RIGHT)
	 */
	public void executeTurn(Rotation rotation)
	{
		game.communicateRobot(new TurnInstruction(rotation));
	}
	
	public void executeStormAction()
	{
		game.communicateRobot(new StormInstruction());
	}
	
	public void executeDefuseAction(String item)
	{
		game.communicateRobot(new DefuseInstruction(item));
	}
	
	public void executeTriggerAction(String item)
	{
		game.communicateRobot(new TriggerInstruction(item));
	}

}
